{% extends "base.html" %}
{% block body %}
{% import "macros.html" as macros %}
{% import "macros_modal.html" as modal_macros %}

<div id="main" role="main">

    {% if album.label == 'recycle' %}
  	<ol class="breadcrumb">
		<li><a href="{{ url_for('pic.home') }}">Home</a></li>
		<li><a href="{{ url_for('work.home') }}">Work</a></li>
		<li class="active">{{ album.label|title }}</li>
	</ol>
    {% endif %}

    <center>
        <div class="album-title">
            <h5>
                {{album.label | title}}
                {% if not album.fake %}
                    : {{ album.name }}
                    <span class="pull-right">
                        <input type="button" class="btn btn-xs btn-default" data-toggle="modal" data-target="#album_modify_modal" value="修改">
                    </span>
                {% endif %}

                {% if album.label == 'explore' %}
                    <a class="btn btn-default btn-xs" onclick="setUrlParams({'unfiled': '1','clear': '1'})">只看未分类的图片</a>
                    <small> / </small>
                    <a class="btn btn-default btn-xs" onclick="setUrlParams({'unfiled': '', 'clear': ''})">随机图片</a>
                {% elif album.label == 'recycle' %}
                    <input type="button" class="btn btn-warning btn-xs pull-right" value="清空" id="recycle_empty_btn">
                {% else %}
                    {% if request.args.get('clear') %}
                        <a class="btn btn-default btn-xs" onclick="setUrlParams({'clear': ''})">普通视图</a>
                    {% else %}
                        <a class="btn btn-default btn-xs" onclick="setUrlParams({'clear': '1'})">简洁视图</a>
                    {% endif %}
                    {% if album.label in ('album', 'actress') and volume_count %}
                        {% if request.args.volume_clear %}
                            <a class="btn btn-default btn-xs" onclick="setUrlParams({'volume_clear': ''})">显示卷中的图片</a>
                        {% else %}
                            <a class="btn btn-default btn-xs" onclick="setUrlParams({'volume_clear': '1'})">隐藏卷中的图片</a>

                        {% endif %}
                    {% endif %}
                    {% if album.base_album %}
                        <a href="{{ url_for('pic.one_base_album', uid=album.base_album_id) }}" class="btn btn-default btn-xs">{{ album.base_album.name }}</a>
                    {% endif %}

                    {% if album.label == 'volume' %}
                        <a href="{{url_for('pic.one_actress', uid=album.actress.id)}}" class="btn btn-default btn-xs">模特:{{album.actress.name}}</a>
                    {% endif %}
                {% endif %}
                <br>
                </h5>
                <p>
                    图片数量: {{album.amount}}
                    {% if not album.fake %}| pv: {{ album.pv }} | 创建日期: {{ album.create_time }}{%endif%}
                </p>

            <div class="row">
                {% if album.note or volume_count %}
                    <div class="col-sm-9 col-xs-12">
                        <div class="album-note">
                            {% if volume_count %}
                                <a href="{{ url_for('pic.volumes', id=album.id, all=1) }}">Volumes</a>:
                                {% for vol in volumes %}
                                    &nbsp;&nbsp;<a href="{{ url_for('pic.one_volume', uid=vol.id, all=1) }}">{{vol.name}}({{siteinfo.get_cache('volume', vol.id).get('count')}})</a>
                                {% endfor %}

                            {% endif %}
                            <p>{{album.note_html() | default('', boolean=True) | safe}}</p>
                        </div>
                    </div>
                {% endif %}

                {% if album.label in ('album','volume', 'actress')  %}
                    <div class="col-sm-3 col-xs-12">
                        {{ macros.rating(album) }}
                    </div>
                {% endif %}
            </div>

            {{ macros.album_tools(album, siteinfo) }}

        </div>
    </center>
    <form id="batch_deal" method="post">
        <ul id="tiles">
            <!-- These are our grid blocks -->
            {% for pic in pics %}
            <li>
                    <a href="{{url_for('pic.one_pic',source=source,source_id=source_id,uid=pic.id)}}">
                        {{ pic.thumbnail_link | safe }}
                    </a>
                    {{pic.file_type_label|safe}}

                {% if not clear %}
                <div class="post-info">
                    <div class="post-basic-info">
                        <p>{{ pic.note_html() | safe }}</p>
                        <p>{{pic.actresses_html() | safe}}</p>
                        <p>{{pic.volumes_html() | safe}}</p>
                        <p>{{pic.albums_html() | safe}}</p>
                        <p>{{pic.tags_html() | safe}}</p>
                    </div>
                    <div class="post-info-rate">
                        {{ pic.rate_html() | safe }}{{ pic.pv_html() | safe }}
                    </div>
                    <input type="checkbox" class="pics_chk" name="pics_chk" value="{{pic.id}}">
                    <div class="clear"> </div>
                </div>
                {% endif %}
            </li>
            {% endfor %}
            <!-- End of grid blocks -->
        </ul>
    </form>
</div>


{% if not album.fake %}
    {{ modal_macros.album_modify_modal(album) }}
{% endif %}

{% endblock %}


{% block script %}
<!--wookmark-scripts-->
<script type="text/javascript">
// ajax加载更多图片 start
js_more_pics = {
        "page": parseInt("{{page | default(0, true)}}"),
        "url": "{{url_for('api.more_pic')}}",
        "ajax_post_data": {
            'source': "{{album.label}}",
            'source_id': "{{album.id}}",
            'clear': "{{request.args.get('clear', '')}}",
            'volume_clear': '{{request.args.volume_clear}}',
            "all": "{{request.args.all}}",
            "unfiled": "{{request.args.unfiled}}",
            "note": "{{ request.args.note }}",
            "album_id": "{{ request.args.album_id }}",
            "actress_id": "{{ request.args.actress_id }}",
            "volume_id": "{{ request.args.volume_id }}",
            "tag_id": "{{ request.args.tag_id }}",
            "limit": "{{ request.args.limit }}",
        }
};
load_more_pics()  // 加载第一页图片
// ajax加载更多图片 end

js_album = {
        'id': "{{album.id}}",
        'label': "{{album.label}}",
        'title': "{{album.name}}",
        'cover_id': "{{album.cover_id}}",
        'download_url': "{{url_for('api.download_api')}}",
        'join_albums_url': "{{url_for('api.batch_join_albums')}}",
        'move_out_album_url': "{{url_for('api.move_out_pic')}}",
        'delete_tag_album_url': "{{url_for('api.delete')}}",
        'modify_album_url':"{{url_for('api.modify_album')}}",
        'set_cover_url': "{{url_for('api.set_cover')}}",
        'delete_pics_url': "{{url_for('api.bulk_delete')}}",
        'recycle_restore': "{{url_for('api.recycle_restore')}}",
        'recycle_delete': "{{url_for('api.recycle_delete')}}",
    }
js_pic = {
    "note_edit_url": "{{url_for('api.note')}}",
    "rating_url": "{{url_for('api.rate')}}",
}

let tiles_ul = document.getElementById('tiles');

tiles_ul.addEventListener('dblclick', noteDblClick);


document.addEventListener("keydown", function(event) {
    //当焦点处于body或checkbox时允许触发快捷键
    if (document.activeElement.tagName === 'BODY' || document.activeElement.type ==='checkbox'){
        // 图片比较
        if (event.key==='d' || event.key==='D') {
            $('#compare_btn').click()
        }
        // 全选图片
        else if(event.key==='a' || event.key==='A'){
            $("#select_all").click()
        }
        // 取消选中图片
        else if(event.key==='c' || event.key==='C'){
            $("#cancel_select").click()
        }
    }
});

load_filter("{%if not album.fake %}{%if album.label =='actress' %}{{album.name}}{% elif album.label == 'volume' %}{{album.actress.name}}{% endif %}{% endif %}", "{{url_for('api.load_filter', timestamp=siteinfo.cache_refresh_time('album'))}}")
</script>
<!--//wookmark-scripts-->
{% endblock %}
